package com.hjm.project.bankInfo.bankInfo.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.bankInfo.bankInfo.domain.QbBankInfo;
import com.hjm.project.bankInfo.bankInfo.service.IQbBankInfoService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 钱宝银行卡信息Controller
 * 
 * @author LOVE
 * @date 2020-11-19
 */
@Controller
@RequestMapping("/bankInfo/bankInfo")
public class QbBankInfoController extends BaseController
{
    private String prefix = "bankInfo/bankInfo";

    @Autowired
    private IQbBankInfoService qbBankInfoService;

    @RequiresPermissions("bankInfo:bankInfo:view")
    @GetMapping()
    public String bankInfo()
    {
        return prefix + "/bankInfo";
    }

    /**
     * 查询钱宝银行卡信息列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(QbBankInfo qbBankInfo)
    {
        startPage();
        List<QbBankInfo> list = qbBankInfoService.selectQbBankInfoList(qbBankInfo);
        return getDataTable(list);
    }

    /**
     * 获取支行
     */
    @PostMapping("/list2")
    @ResponseBody
    public TableDataInfo list2(@RequestParam Map map) {
        startPage();
        List<Map<String, Object>> qbBranchBank = qbBankInfoService.findQBBranchBank(map);
        return getDataTable(qbBranchBank);
    }




    /**
     * 查询钱宝银行卡信息列表
     */
    @PostMapping("/list1")
    @ResponseBody
    public TableDataInfo list1(@RequestParam Map map)
    {
        startPage();
        List<Map> headBank = qbBankInfoService.findHeadBank(map);
        return getDataTable(headBank);
    }

    /**
     * 查询钱宝银行卡信息列表
     */
    @PostMapping("/headList")
    @ResponseBody
    public TableDataInfo headList(QbBankInfo qbBankInfo)
    {
        startPage();
        List<QbBankInfo> headBank = qbBankInfoService.selectHeadList(qbBankInfo);
        return getDataTable(headBank);
    }

    /**
     * 导出钱宝银行卡信息列表
     */
    @RequiresPermissions("bankInfo:bankInfo:export")
    @Log(title = "钱宝银行卡信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QbBankInfo qbBankInfo)
    {
        List<QbBankInfo> list = qbBankInfoService.selectQbBankInfoList(qbBankInfo);
        ExcelUtil<QbBankInfo> util = new ExcelUtil<QbBankInfo>(QbBankInfo.class);
        return util.exportExcel(list, "bankInfo");
    }

    /**
     * 新增钱宝银行卡信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存钱宝银行卡信息
     */
    @RequiresPermissions("bankInfo:bankInfo:add")
    @Log(title = "钱宝银行卡信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(QbBankInfo qbBankInfo)
    {
        return toAjax(qbBankInfoService.insertQbBankInfo(qbBankInfo));
    }

    /**
     * 修改钱宝银行卡信息
     */
    @GetMapping("/edit/{bankName}")
    public String edit(@PathVariable("bankName") String bankName, ModelMap mmap)
    {
        QbBankInfo qbBankInfo = qbBankInfoService.selectQbBankInfoById(bankName);
        mmap.put("qbBankInfo", qbBankInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存钱宝银行卡信息
     */
    @RequiresPermissions("bankInfo:bankInfo:edit")
    @Log(title = "钱宝银行卡信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(QbBankInfo qbBankInfo)
    {
        return toAjax(qbBankInfoService.updateQbBankInfo(qbBankInfo));
    }

    /**
     * 删除钱宝银行卡信息
     */
    @RequiresPermissions("bankInfo:bankInfo:remove")
    @Log(title = "钱宝银行卡信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(qbBankInfoService.deleteQbBankInfoByIds(ids));
    }
}
